<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>任务管理应用</title>
  <script src="https://cdn.jsdelivr.net/npm/vue@2.6.14/dist/vue.js"></script>
  <style>
    body {
      font-family: Arial, sans-serif;
      background-color: #f4f4f4;
      padding: 20px;
    }
   .task-item {
      background-color: white;
      padding: 10px;
      margin-bottom: 10px;
      border: 1px solid #ccc;
    }
    button {
      background-color: #007BFF;
      color: white;
      padding: 5px 10px;
      border: none;
      cursor: pointer;
    }
    input[type="text"] {
      padding: 5px;
      border: 1px solid #ccc;
      cursor: pointer;
    }
  </style>
</head>

<body>
  <div id="app">
    <h1>任务管理应用</h1>
    <input type="text" v-model="newTask" placeholder="输入新任务">
    <button @click="addTask">添加任务</button>
    <h2>所有任务</h2>
    <ul>
      <li v-for="(task, index) in tasks" :key="index" class="task-item">
        <input type="checkbox" v-model="task.completed">
        <span>{{ task.name }}</span>
        <button @click="removeTask(index)">删除</button>
      </li>
    </ul>
    <h2>未完成任务</h2>
    <ul>
      <li v-for="(task, index) in unfinishedTasks" :key="index" class="task-item">
        <input type="checkbox" v-model="task.completed">
        <span>{{ task.name }}</span>
        <button @click="removeTask(index)">删除</button>
      </li>
    </ul>
    <h2>已完成任务</h2>
    <ul>
      <li v-for="(task, index) in completedTasks" :key="index" class="task-item">
        <input type="checkbox" v-model="task.completed">
        <span>{{ task.name }}</span>
        <button @click="removeTask(index)">删除</button>
    </ul>
   
  </div>

  <script>
    // 创建Vue实例
    new Vue({
      el: '#app',
      data: {
        newTask: '',
        newTaskPriority: '',
        tasks: []
      },
      computed: {
        unfinishedTasks() {
          return this.tasks.filter(task =>!task.completed);
        },
        completedTasks() {
          return this.tasks.filter(task => task.completed);
        }
      },
      methods: {
        addTask() {
          if (this.newTask!== '') {
            this.tasks.push({
              name: this.newTask,
              completed: false
            });
            this.newTask = '';
          }
        },
        removeTask(index) {
          this.tasks.splice(index, 1);
        }
      }
    });
  </script>
</body>

</html>